package com.pro.staffmanage.controller;

import com.pro.staffmanage.pojo.User;
import com.pro.staffmanage.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;

/**
 * @Author: Haotian Cui
 * @Date: 2022/7/23 - 07 - 23 - 17:09
 * @Description: com.pro.staffmanage.config
 * @Project: staffmanage
 * @version: 1.0
 */
@Controller
public class UserController {

    private UserService userService;

    @Autowired
    public UserController(UserService userService){
        this.userService = userService;
    }

    @GetMapping("/reg")
    public String register(User user){
        userService.addUser(user);
        return "redirect:/";
    }

    @GetMapping("/")
    public String login(){
        return "index";
    }

    @GetMapping("/index")
    public String i18n(){
        return "index";
    }

    @DeleteMapping("/logout")
    public String logout(){
        return "index";
    }

    @GetMapping("/main")
    public String wrapMainPage(){
        return "dashboard";
    }

}
